package com.example.fmgidsprototype.data;

import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;
import android.util.Log;

public class VenueLocationTable {
	
	public static final String TABLE_NAME = "VenueLocation";
	
	public static class VenueLocationColumns implements BaseColumns{
		public static final String VENUE = "venue";
		public static final String LONGITUDE = "longitude";
		public static final String LATITUDE = "latitude";
		public static final String DISTANCE_FROM_ZERO = "distance_from_point_zero";
	}
	
	public static void onCreate(SQLiteDatabase db){
		StringBuilder sb = new StringBuilder();
		sb.append("create table if not exists " + VenueLocationTable.TABLE_NAME + " (");
		sb.append(BaseColumns._ID + " integer primary key, ");
		sb.append(VenueLocationColumns.VENUE + " integer not null ,");
		sb.append(VenueLocationColumns.LONGITUDE + " numeric not null ,");
		sb.append(VenueLocationColumns.LATITUDE + " numeric not null ,");
		sb.append(VenueLocationColumns.DISTANCE_FROM_ZERO + " numeric, ");
		sb.append("foreign key(" + VenueLocationColumns.VENUE + ") references ");
		sb.append(VenueTable.TABLE_NAME + "(" + BaseColumns._ID + ")");
		sb.append(")");
		Log.d("VENLOCCREATE", "create: " + sb.toString());
		db.execSQL(sb.toString());
	}
	
	public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
		db.execSQL("drop table if exists " + VenueLocationTable.TABLE_NAME);
		onCreate(db);
	}

}
